package com.hy.mydesktop.client.mvc.base;

import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.hy.mydesktop.client.mvc.desktop.DesktopController;
import com.hy.mydesktop.shared.util.log.MyLoggerUtil;

/**
 * 
 * 
 * <ul>
 * <li>开发作者：花宏宇</li>
 * <li>设计日期：2012-1-29；时间：下午03:25:56</li>
 * <li>类型名称：BasePresenterAndViewTemplate</li>
 * <li>设计目的：具体的Presenter，的initiaite方法中的用到的辅助类</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
public class BasePresenterAndViewTemplate {
	
	public static final String className = "com.hy.mydesktop.client.mvc.base.BasePresenterAndViewTemplate";
	
	public static void constructPresenter(BasePresenterAndView presenter,Controller controller,BaseDisplay display) {
		
		//this.display = display;
		//((BaseController)controller).getPresenter().getDisplay().add(display.getComponent());
//		presenter.getDisplay().add(display.getComponent());
//		presenter.getDisplay().add(display.getComponent());
		((BaseController)controller).setPresenter(presenter);
		if (((BaseController)controller).getParent()!=null) {
			BaseController parentController =(BaseController)(((BaseController)controller).getParent());
			if (parentController instanceof DesktopController) {
				//MyLoggerUtil.printDebug(className, "DesktopController 无 Com")
			} else {
				Component component= parentController.getPresenter().getDisplay().getComponent();
				LayoutContainer layoutContainer = null;
				if (component instanceof LayoutContainer) {
					layoutContainer= (LayoutContainer)component;
					layoutContainer.add(presenter.getDisplay().getComponent());
					//MyLoggerUtil.printDebug(className, "控制器"+controller+"(对应控件"+presenter.getDisplay().getComponent().getClass().getName()+")"+"的父控制器是"+parentController+"(对应控件"+((LayoutContainer)presenter.getDisplay().getComponent().getParent()).getClass().getName()+")");
				MyLoggerUtil.printContollerAnndComponentDebug(BasePresenterAndViewTemplate.class,controller,parentController,presenter);
				
				}
			}


			

		} 
	}

}
